﻿/*
* @Author： whg
* @Date : 2021-1-19
* @Desc : 
*/
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using XNodeEditor;
[XNodeEditor.NodeEditor.CustomNodeEditor(typeof(ActorNode))]
public class ActorEditor : NodeEditor
{
    private ActorNode node;
    public override void OnBodyGUI()
    {
        serializedObject.Update();
        if (node == null) node = target as ActorNode;

        NodeEditorGUILayout.PortField(target.GetInputPort("upLink"));
        EditorGUILayout.Space();
        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("actorType"));
        EditorGUIUtility.labelWidth = 100;
        switch (node.actorType)
        {
            case ActorNode.ActorType.ActorCreate:
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("createTarget"));
                //NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("CreateContent"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Create_res_id"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Create_pos"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Create_scale"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Create_angle"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("special"));
                break;
            case ActorNode.ActorType.ActorDelete:
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("DeleteContent"));
                break;
            case ActorNode.ActorType.ActorSetting:
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Setting_ins_id"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Setting_position"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Setting_angle"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Setting_speed"));
                break;
            case ActorNode.ActorType.ActorMove:
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("actorMoveType"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Move_ins_id"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Move_speed"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Move_rotate_speed"));
                switch (node.actorMoveType)
                {
                    case ActorNode.ActorMoveType.寻路像素坐标:
                        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Move_Point"));
                        break;
                    case ActorNode.ActorMoveType.曲线运动:
                        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Move_start_point"));
                        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Move_end_point"));
                        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Move_curve_list"));
                        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Move_content"));
                        break;
                }
                break;
            case ActorNode.ActorType.ActorRide:
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("isRide"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Ride_ins_id"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Ride_anim"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Ride_id"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Ride_pos"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Ride_rotate"));
                break;
            case ActorNode.ActorType.ActorPlay:
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Play_ins_id"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Play_wait"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Play_precondition"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Play_name"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Play_time"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Play_end_animation"));
                break;
            case ActorNode.ActorType.ActorAction:
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Action_ins_id"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Action_content"));
                break;
            case ActorNode.ActorType.ActorHide:
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Hide_wait"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Hide_target"));
                if(node.Hide_target == ActorNode.HideTarget.MainRole)
                {
                    NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("isHide"));
                }
                else
                {
                    NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Hide_ins_id"));
                    NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Hide_name"));
                    NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("isHide"));
                }
                break;
            case ActorNode.ActorType.ActorShadowMatrix:
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("ShadowMatrix_ins_id"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("ShadowMatrix_position"));
                break;
            default:
                break;
        }
        NodeEditorGUILayout.PortField(target.GetOutputPort("downLink"));
        serializedObject.ApplyModifiedProperties();
    }

}
